package main

import (
	"fmt"
	"log"
	"os"
)

var (
	newFile *os.File
	err error
)

func main(){
	newFile,err = os.Create("test.txt")
	if (err!=nil) {
		log.Fatal(err)
	}else {
		file,Err := os.OpenFile("test.txt",os.O_CREATE|os.O_WRONLY,0)
		if (Err!=nil){
			fmt.Println("打开文件失败")
		}else{
			fmt.Fprintf(file,"Hello World\n")
			file.Close()
			fmt.Fprintf(os.Stdout,"创建成功！\n")
		}
	}
}